# This file is part of pyDC software
# Copyright 2002-2003 Anakim Border <aborder@users.sourceforge.net>
#
# pyDC is released under the terms of GPL licence.
# modified by Pavel C <pavelch+dcbot@gmail.com>
# src site: https://code.google.com/p/dc-bot/

class DCUser:
	CONN_NONE = -1
	CONN_56K = 0
	CONN_SATELLITE = 1
	CONN_DSL = 2
	CONN_CABLE = 3
	CONN_T1 = 4
	CONN_T3 = 5
	
	def __init__(self):
		self.op = 0
		self.nick = None
		self.share = long(-1)
		self.description = None
		self.connection = self.CONN_NONE
		self.email = None
		self.hub = None

	def isOp(self):
		return self.op

	def getNick(self):
		return self.nick

	def getShare(self):
		return self.share

	def getDescription(self):
		return self.description

	def getConnection(self):
		return self.connection

	def getEmail(self):
		return self.email

	def getHub(self):
		return self.hub
		
	def __str__(self):
		s  = "=== DCUser ===\n"
		s += "Op: " + `self.op` + "\n"
		s += "Nick: " + self.nick + "\n"
		s += "Share: " + `self.share` + "\n"
		s += "Description: "
		if self.description != None: s + self.description
		s += "\n"
		s += "Connection: " + `self.connection` + "\n"
		s += "Email: "
		if self.email != None: s = s + self.email
		s += "\n"
		s += "Hub: "
		if self.hub != None: s = s + self.hub.getName()
		
		return s

	def gettUser(user):		
		
		return {
			'NI':user.nick,
			'DE':user.description,
			'EM':user.email,
			'SSshort':user.share,
			'SS':user.share,
			'TA':'',
			'HL':user.hub.getHubUrl(),
		}
	#$s=~s/\[NICK\]/$tUser->{NI}/g;
    #$s=~s/\[DESC\]/$tUser->{DE}/g;
    #$s=~s/\[EMAIL\]/$tUser->{EM}/g;
    #$s=~s/\[IP\]/$tUser->{I4}/g;
    #$s=~s/\[SHORTSHARE\]/$tUser->{SSshort}/g;
    #$s=~s/\[SHARE\]/$tUser->{SS}/g;
    #$s=~s/\[TAG\]/$tUser->{TA}/g;
    #$s=~s/\[HUBNAME\]/$tUser->{HL}/g;

	#"user":{"IO":"0","DE":"[] [2]4G","U4":"0","HO":"2","T4":"0","US":"100","CO":
	#"100","SU":"","VE":"StrgDC++ V:2.06","TA":"","NI":"Atum","SI":"0","OP":"1",
	#"HL":"10.9.31.249:411","GN":"1","HN":"0","TAG":"<StrgDC++ V:2.06,M:A,H:0/0/2,S:5>",
	#"LD":"0","ST":"49","SF":"0","EM":"","SSshort":"1023,70 ","ON":"1","UL":"0","D4":"0",
	#"SL":"5","TL":"1","I4":"","BO":"0","HR":"0","LOC":"","CT":"0","SS":"1099184662502"}
